Titanium.include('general/GeneralVariables.js');
Titanium.include('general/GeneralFunctions.js');
Titanium.include('helpers/TwitterTabGroup.js');

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#FFF');

Titanium.UI.orientation = orientation;

var win1;
var commentWindow;
var firstTimerTwitter = true;

_createTwitterTabGroup();

Ti.App.addEventListener('openTwitterWindow', function() {
	win1.close();
	if (!isAndroid)
	{
		if (firstTimerTwitter)
		{
			twitterTabGroup.open();
		}
		setTimeout(function(){
			twitterTabGroup.animate({
				bottom: 0,
				duration: 500
			});
			twitterTabGroup.bottom = 0;
			trace(twitterTabGroup.bottom);
		}, 1000);
	}
});

Ti.App.addEventListener('closeTwitterWindow', function() {
	win1.open();
	if (!isAndroid)
	{
		twitterTabGroup.animate({
			bottom: 0,
			duration: 500
		});
	}
});

Ti.App.addEventListener('openComments', function(){
	commentWindow.open();
});

Ti.App.addEventListener('closeComments', function(){
	commentWindow.close();
});

win1 = Titanium.UI.createWindow({  
	url: 'windows/HomeWindow.js',
	orientationModes: orientations,
    backgroundColor: '#fff'
});

commentWindow = Titanium.UI.createWindow({
	url: 'windows/commentWindow.js',
	title: 'Reaxies',
	modal: true,
	orientationModes: [Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT],
	data: [
	       [{name: 'naam', comment: 'Dit is mijn veel langere commentaar, kijkt maar eens wat je daarmee doet, haha!', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}],
	       [{name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}, {name: 'naam', comment: 'commentaar', date: 'datum'}]
	        ].reverse()
});

var twitterMixed = Titanium.UI.createWindow({
	url: 'windows/TwitterWindow.js',
	searchUrl: 'http://search.twitter.com/search.json?&q=ype+willem',
	title: 'Alle Tweets',
	react: true,
	orientationModes: [Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT]
});

var twitterYpe = Titanium.UI.createWindow({
	url: 'windows/TwitterWindow.js',
	title: 'Tweets Ype',
	searchUrl: 'http://search.twitter.com/search.json?&q=ypewillem',
	orientationModes: [Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT]
});

var twitterWillem = Titanium.UI.createWindow({
	url: 'windows/TwitterWindow.js',
	searchUrl: 'http://search.twitter.com/search.json?&q=willemype',
	title: 'Tweets Willem',
	orientationModes: [Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT]
});

if (!isAndroid)
{
	_addTwitterTabs();
}

win1.open();